<template>
    <div class="iot_DeleteBox">
        <div><img src="../assets/icons/logo/logo_icon.png" alt=""></div>
        <div v-for="items in RegisterImformation" :key="items.acoount" class="iot_item">
            <P>用户名:<span>{{ items.username }}</span></P>
            <P>账号:<span>{{ items.account }}</span></P>
            <div><van-button type="success" @click="Delete(items.account)">删除</van-button></div>
        </div>
    </div>
</template>

<script>
import { inject } from 'vue';

export default {
    setup(){
        let RegisterImformation = inject('RegisterImformation')
        //删除函数
        function Delete(Account){
            for(let i = 0; i < RegisterImformation.length;i++){
                if(RegisterImformation[i].account == Account){
                    RegisterImformation.splice(i,1);
                    localStorage.setItem('Register',JSON.stringify(RegisterImformation))
                    break
                }
            }
        }
        return{RegisterImformation,Delete}
    }
}
</script>

<style scoped>
.iot_DeleteBox{
    max-height: 400px;
    overflow: auto;
}
.iot_DeleteBox::-webkit-scrollbar{
        width: 0px;
}
p{
    margin: 0;
    color: #28ba9b;
}
button{
    position: absolute;
    right: 0;
    top: 0;
    width: 30px;
    height: 48px;
    border: 0;
    background-color: #f56c6c;
}
span{
    display: inline-block;
    width: 194.4px;
    height: 24px;
    margin: 0 0 0 10px;
    color: #2c3e50;
    text-align: left;
}
.iot_item{
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: end;
    margin-bottom: 20px;
}
img{
    width: 60px;
    margin: 0 0 20px;
}
</style>